package com.furongji.education.controller.admin;

import com.furongji.common.result.Result;
import com.furongji.education.utils.AliyunVodOperator;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@Tag(name = "阿里云视频点播")
@AllArgsConstructor
@RestController
@RequestMapping("/admin/vod")
public class VodAdminController {

    private AliyunVodOperator vodOperator;

    @Operation(summary = "上传课程视频")
    @PostMapping("/video")
    public Result uploadVideo(MultipartFile file) throws Exception {
        String videoId = vodOperator.UploadVideo(file);
        return Result.success(videoId);
    }


    @Operation(summary = "删除课程视频")
    @DeleteMapping("/removeVideo/{id}")
    public Result removeVideo(@PathVariable String id) throws InterruptedException {
        Thread.sleep(10000);
        vodOperator.removeVideo(id);
        return Result.success();
    }

    @Operation(summary = "批量删除视频")
    @DeleteMapping("/removeVideoList")
    public Result removeVideoList(@RequestParam(value = "videoIdList") List<String> videoIdList) {
        vodOperator.removeVideoList(videoIdList);
        return Result.success();
    }
}
